package com.makefuture.service;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.makefuture.model.TUser;
import com.makefuture.utils.ExcelExportUtil;
import com.makefuture.utils.ExcelExportUtil.Pair;

public class ExportService{
	
	public static ExportService service = new ExportService();

	/**
	 * 导出数据
	 * @param response
	 * @param request
	 * @param member
	 */
	public void export(HttpServletResponse response, HttpServletRequest request, List<TUser> members) {
		
		List<Pair> titles = new ArrayList<Pair>();
		
		List<Record> list = Db.find("select name from syscolumns where id=object_id('t_user') ");//mysql show full columns from member
		
		for(Record r : list) {
			
			String value = r.get("name");
			
			String key = r.get("name");
			
			titles.add(new Pair(key, value));
		}
		
		
		// 特殊处理
//		for (Member member : Member) {
//			
//		}
//		
		ExcelExportUtil.exportByRecord(response, request, "exportExcel", titles , members);
	}
}
